#include <QApplication>
#include "mainwindow.h"
#include "application.h"
#include <QCommandLineParser>
#include <QDebug>
#include "debug.h"
#include "version.h"

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QCoreApplication::setApplicationName("Application");
    QCoreApplication::setOrganizationName("xxx");
    QCoreApplication::setApplicationVersion(APP_VERSION);

    const QIcon icon = QIcon("./images/application.png");
    a.setWindowIcon(icon);

    qInstallMessageHandler(myMessageOutput);
#ifdef Q_OS_LINUX
    qInstallSigactionHandler("./work/application");
#endif
//    qApp->installEventFilter(WindowFilter::instance());

    qDebug() << "This program is builded on " << __DATE__ << __TIME__;

    Application::getInstance()->start();

    QCommandLineParser parser;
    parser.setApplicationDescription("Qt MDI Example");
    parser.addHelpOption();
    parser.addVersionOption();
    parser.addPositionalArgument("file", "The file to open.");
    parser.process(a);

    MainWindow w;
    const QStringList posArgs = parser.positionalArguments();
    for (const QString &fileName : posArgs)
        w.openFile(fileName);

//    w.resize(800*2, 480*2);
//    w.resize(800, 480);
    w.show();

    return a.exec();
}
